<template>
    <div class="">
      <div class="tabs-body">
        <el-switch  :disabled="typeDisabled" v-model="indexTypeValue" active-value="2" inactive-value="1" active-color="#13ce66" inactive-color="#1890ff"
          active-text="海岛" inactive-text="默认首页" @change="typeChange">
        </el-switch>
      </div>
    </div>
    </template>
    <script>
    import {
      modifyfootprintIndexType,
      footprintIndexType
    } from "@/api/incentiveManagement/dyConfig";
    export default {
      name: "travelCheckIn",
      props: {},
      data() {
        return {
          indexTypeValue:'1',//页面类型 1 正常页面 2 抽奖页面
          typeDisabled:false
        };
      },
      watch: {},
      created() {
        this.getIndexType()
      },
      mounted() { },
      methods: {
        //获取首页类型
        getIndexType() {
          footprintIndexType().then((res) => {
            this.indexTypeValue = res.result.type
          });
        },
        //首页类型选择
        typeChange(){
          let data = {
            type: this.indexTypeValue
          }
          console.log(this.indexTypeValue)
          this.typeDisabled = true
          modifyfootprintIndexType(data).then((res) => {
            this.$message.success('操作成功');
            this.typeDisabled = false
            this.getIndexType()
          }).catch(()=>{
            this.typeDisabled = false
            this.getIndexType()
          })
        },
       
      },
    };
    </script>
    <style lang="scss" scoped>
    .tabs-body {
      background-color: #fff;
      padding: 20px;
    }
    
   </style>
      